<!--搜索弹出框内 搜索组建-->
<template>
    <a-modal style="position:relative;z-index:10000" :destroyOnClose="true" :title="`请选择${dynamicData.name}`" :visible="tableShow" @cancel="onclose">
        <div :id="boxId" ref="searchInput">
            <a-input-search ref="inputRef" :placeholder="`请选择${dynamicData.name}`" v-model="inputValue" @focus="showModal" @change="inputSearch" @search="inputSearch" @pressEnter="clickEnter" />
            <div class="form-search-wrapper" ref="searchWrapper" v-show="tableShow" style="min-height:182px;">
                <a-table :scroll="{x:300,y:180}" :columns="columns" :data-source="tableData" :customRow="customClick" bordered :pagination="pagination" >

                </a-table>
            </div>
        </div>
        <template slot="footer">
            <a-button type="primary" @click="clearChoice">清空</a-button>
        </template>
    </a-modal>
</template>
<script>
import { mapState } from "vuex";
import { getAction, postAction } from "@/api/manage";
import { officeUserListToTree } from "@/utils/tree";

export default {
    props: {
        dynamicData: {
            type: Array,
            default: () => []
        },
        searchData: {    //搜索条件对象
            type: Object,
            default: {}
        }
    },
    watch: {
        // dynamicData: {
        //     handler(newName, oldName) {
        //         this.inputValue = this.dynamicData.value;
        //     },
        //     deep: true
        // },
    },
    data () {
        return {
            boxId: null,             //当前容器id
            codesName: null,         //当前组建名称
            columns: [],

            pagination: {
                current: 1,
                pageSize: 10,
                total: 0,
                size: 'small',
                onChange: (page, pageSize) => {
                    // this.postData.current = page;
                    this.pagination.current = page;
                    this.pagination.pageSize = pageSize;
                    this.pageList();
                }
            },
            postData: {},
            tableData: [],
            customClick: (record, index) => ({
                on: {
                    click: (event) => {
                        event.preventDefault();
                        this.clickEnter('click', record);

                    },
                },
            }),
            tableShow: false,
            isRun: false,
            setTime: null,  //延迟请求
            id: null,       //当前选择的搜索id
            tableBody: null,
            apiUrl: null,
            inputValue: '',  //输入框的值
        }
    },
    created () {
        this.checkSearch();

        if (this.$route.path == '/inventory/bills/InitialInventory') {
            this.pageList('warehouse');
        }


        //发票
        if (this.$route.path == '/procurement/purchaseInvoice') {
            this.pageList('invoice');
        }
    },
    computed: {
        ...mapState({
            wherehouseId: state => state.order.wherehouseId,
        }),
    },
    mounted () {
        // document.addEventListener('click', (e) => {
        //     //获取弹出表格对象
        //     if (this.tableShow && this.boxId != null) {
        //         const userCon = document.getElementById(this.boxId);

        //         //判断表格对象中是否包含点击对象
        //         if (userCon && !userCon.contains(e.target)) {

        //             //删除操作
        //             if (this.inputValue == '') {
        //                 console.log(this.codesName)
        //                 let data = Object.assign({}, { codesName: this.codesName })
        //                 this.$emit('clickItem', data);
        //             } else {
        //                 if (this.id) {
        //                     let data = this.tableData.filter(item => item.id == this.id);
        //                     this.inputValue = data[0].name;
        //                 }
        //             }
        //             this.tableShow = false
        //         }
        //     }

        // })
        var _this = this;
        window.onresize = () => {
            _this.tableShow = false
        }

        // 判断table的滚动条是否到达底部
        // this.tableBody = document.getElementById(this.boxId).getElementsByClassName('ant-table-body');
        // this.tableBody[0].onscroll = function () {
        //     // scrollTop + clientHeight == scrollHeight
        //     //  scrollTop为滚动条在Y轴上的滚动距离。
        //     // clientHeight为内容可视区域的高度。
        //     // scrollHeight为内容可视区域的高度加上溢出（滚动）的距离。
        //     if (_this.tableBody[0].scrollTop + _this.tableBody[0].clientHeight == _this.tableBody[0].scrollHeight) {
        //         console.log('我到底部了')
        //         // _this.pagination.current++;
        //         // _this.pageList();
        //     }
        // }
    },
    methods: {
        clearChoice () {
            //置空选择
            this.clickEnter('click', { id: null, name: null, });
        },
        pageList (code) {
            this.checkSearch();
            console.log(this.isRun);
            if (!this.isRun) {
                this.isRun = true;
                this.postData.current = this.pagination.current
                this.postData.size = this.pagination.pageSize
                this.postData['page.current'] = this.pagination.current
                this.postData['page.size'] = this.pagination.pageSize
                if(this.$route.path == '/production/management/productionOrder' && code == "createUserId"){
                    this.apiUrl = 'system/office/getOfficeTreeDataList?isLoadUser=2'
                    this.columns = [
                        { title: "姓名", dataIndex: "name" }
                    ];
                }

                if(this.$route.path == '/production/management/productionOrder' && code == "closerId"){
                    this.apiUrl = 'system/office/getOfficeTreeDataList?isLoadUser=2'
                    this.columns = [
                        { title: "姓名", dataIndex: "name" }
                    ];
                }

                if(this.$route.path == '/production/management/productionOrder' && code == "reviewerUserId"){
                    this.apiUrl = 'system/office/getOfficeTreeDataList?isLoadUser=2'
                    this.columns = [
                        { title: "姓名", dataIndex: "name" }
                    ];
                }

                if(this.$route.path == '/production/productionDemand' && code == "chooseSchemeId"){
                    this.apiUrl = 'system/office/getOfficeTreeDataList?isLoadUser=2'
                    this.columns = [
                        { title: "姓名", dataIndex: "name" }
                    ];
                }
                
                getAction(this.apiUrl, this.postData).then(response => {
                    if (response.code === 200) {
                        this.tableData = []
                        //某些接口没有分页
                        if (this.dynamicData.val == 'clearmethod') {
                            this.tableData = response.data.records;
                            this.isRun = false;
                            return;
                        }
                        
                        if (response.data.total && response.data.total > 0) {
                            //const { records, total, current, size } = response.data;

                            
                            //返回值处理
                            let val = this.dynamicData.val;
                            console.log(val);
                            switch (val) {
                                case 'employees'://业务员
                                    response.data.records.forEach(element => {
                                        this.$set(element, 'name', element.realName);
                                    });
                                    break;
                                case 'crmCustomer'://客户
                                    response.data.records.forEach(element => {
                                        this.$set(element, 'name', element.crmName);
                                    });
                                    break;
                                case 'supplie'://供应商
                                    response.data.records.forEach(element => {
                                        this.$set(element, 'name', element.crmName);
                                    });
                                    break;
                                case 'office'://部门
                                    response.data.records.forEach(element => {
                                        this.$set(element, 'name', element.officeName);
                                    });
                                    break;
                                case 'crm'://客户名称
                                    response.data.records.forEach(element => {
                                        this.$set(element, 'name', element.crmName);
                                    });
                                    break;
                                case 'warehouse'://仓库
                                    response.data.records.forEach(element => {
                                        this.$set(element, 'name', element.whName);
                                    });
                                    break;
                                case 'inventory'://物料名称
                                    response.data.records.forEach(element => {
                                        this.$set(element, 'name', element.inventoryName)
                                    });
                                    break;
                                case 'role'://角色
                                    response.data.records.forEach(element => {
                                        this.$set(element, 'name', element.roleName)
                                    });
                                    break;
                                default:
                                    break;
                            }
                            
                            // const childrenNav = [];
                            // this.officeUserListToTree(response.data.records, childrenNav, "0");
                            // this.tableData.push(response.data[0]);
                            
                            this.tableData = response.data.records



                            //console.log(this.tableData);
                            // let page = {
                            //     total: total,
                            //     pageSize: size,
                            //     current: current
                            // }
                            // this.pagination = Object.assign(this.pagination, page);

                            //this.tableData = records;
                        } else {
                            if (response.data && response.data.length > 0) {
                                let page = {
                                    total: response.data.length,
                                    pageSize: 360,
                                    current: 1
                                }
                                const childrenNav = [];
                                this.officeUserListToTree(response.data.records, childrenNav, "0");
                                this.tableData.push(response.data[0]);

                                this.pagination = Object.assign(this.pagination, page);
                                //this.tableData = response.data;
                            }
                        }
                        this.isRun = false;
                        console.log(this.tableData);
                    }
                }).catch(error => { });
            }
        },
        showModal () {
            this.pageList(this.dynamicData.code);
            this.$nextTick(() => {
                if (this.dynamicData.length > 0) {
                    this.codesName = this.dynamicData.code;
                    this.boxId = this.dynamicData.code;
                }
                // this.inputValue = this.dynamicData.value;
                this.inputValue = this.dynamicData.showvalue ? this.dynamicData.showvalue : this.dynamicData.value;
            })
            this.tableShow = true;
        },
        onclose () {
            this.tableShow = false;
            this.inputValue = '';
        },
        inputSearch () {
            this.tableShow = true;
            let val = this.dynamicData.val;
            switch (val) {
                case 'supplie'://供应商
                    this.postData.keyWord = this.inputValue;
                    break;
                case 'office'://部门
                    this.postData.officeCode = this.inputValue;
                    break;
                case 'employees'://业务员、请购人、检验
                case 'project'://项目
                case 'currency'://币种
                case 'purchaseType'://采购类型
                case 'saleType'://销售类型
                    this.postData.searchKey = this.inputValue;
                    break;
                case 'crm'://客户名称
                    this.postData.keyWord = this.inputValue;
                    break;
                case 'warehouse'://仓库
                    this.postData.keyWord = this.inputValue;
                    break;
                case 'invoiceType'://发票
                    this.postData.searchKey = this.inputValue;
                case 'inventory'://物料名称
                    this.postData.key = this.inputValue;
                    break;
                default:
                    break;
            }
            //延迟请求
            if (this.setTime) {
                clearTimeout(this.setTime)
            }
            this.setTime = setTimeout(() => {
                this.pageList(this.dynamicData.code);
            }, 500)
        },
        clickEnter (type, record) {
            //type == 'click' 表示点击表格事件 else 回车事件
            let data = {};
            if (type == 'click') {
                data = Object.assign(record, { codesName: this.dynamicData.code })
                this.id = record.id;
            } else {
                data = Object.assign(this.tableData[0], { codesName: this.dynamicData.code })
                this.id = this.tableData[0].id;
            }
            this.inputValue = data.name;

            console.log(`${this.dynamicData.name}：${this.dynamicData.code}选中的数据：`, data)

            this.$emit('clickItem', data);
            this.$refs.inputRef.blur();
            this.onclose();
        },
        checkSearch () {

            //当前搜索类型
            // supplie      供应商
            // office       部门
            // employees    业务员、请购人、检验
            // project      项目
            // currency     币种
            // purchaseType 采购类型
            // crm          客户名称
            // saleType     销售类型
            // warehouse    仓库
            // bank         银行账户
            // despatchType     运输方式
            // accountingRadio  会计科目

            let val = this.dynamicData.val;
            switch (val) {
                case 'inventory'://物料名称
                    this.apiUrl = "/in/inventory/getList";
                    this.columns = [
                        { title: "物料编码", dataIndex: "inventoryCode", align: 'left', width: 120 },
                        { title: "物料名称", dataIndex: "inventoryName", align: 'left', width: 120 },
                        { title: "规格型号", dataIndex: "inventorySpecification", align: 'left', width: 80 },
                        {
                            title: "物料属性", dataIndex: "inventoryAttribute", width: 240,
                            customRender: (text, record, index) => {
                                let attribute = [];
                                if (record.isPurchasing) {
                                    attribute.push('允许外购');
                                }
                                if (record.isForSale) {
                                    attribute.push('允许销售');
                                }
                                if (record.isMadeSelf) {
                                    attribute.push('允许自制');
                                }
                                if (record.isMaterial) {
                                    attribute.push('允许生产耗用');
                                }
                                if (record.isLaborCost) {
                                    attribute.push('允许劳务费用');
                                }
                                if (record.isSuite) {
                                    attribute.push('允许成套件');
                                }
                                if (record.isMadeRequest) {
                                    attribute.push('允许委外');
                                }
                                if (record.isInventedKey) {
                                    attribute.push('允许虚拟件');
                                }
                                return attribute.join('，');
                            },
                            ellipsis: true
                        },
                        { title: "计量方式", dataIndex: "unitType", width: 80, align: 'center', }
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        key: this.inputValue
                    }
                    break;
                case 'supplie'://供应商
                    // this.apiUrl = '/vendor/page';
                    this.apiUrl = '/crm/customer/pageForVoucher';
                    this.columns = [
                        // { title: "首拼码", dataIndex: "vendorPym", },
                        { title: "供应商编码", dataIndex: "crmNo", ellipsis: true, },
                        { title: "供应商名称", dataIndex: "crmName", ellipsis: true, },
                        // { title: "类型", dataIndex: "partnerClassId", scopedSlots: { customRender: "partnerClassId" }, },
                        // { title: "联系地址", dataIndex: "address", ellipsis: true, },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        isFinance: 1,
                        companyType: 'isSupplier',
                        keyWord : this.inputValue
                    }
                    break;
                case 'employees'://业务员、请购人、检验
                    this.apiUrl = '/sysUser/user/page';
                    this.columns = [
                        { title: "用户姓名", dataIndex: "realName" },
                        { title: "所属机构", dataIndex: "officeName", ellipsis: true, },
                        { title: "手机号", dataIndex: "mobile" },
                        { title: "电子邮箱", dataIndex: "email", ellipsis: true, },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue
                    }
                    break;
                case 'office'://部门
                    this.apiUrl = '/system/office/page';
                    this.columns = [
                        { title: "编码", dataIndex: "officeCode", },
                        { title: "机构名称", dataIndex: "officeName", ellipsis: true, },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        officeCode: this.inputValue
                    }
                    break;
                case 'project'://项目
                    this.apiUrl = '/erp/project/pageList';
                    this.columns = [
                        { title: "项目编码", dataIndex: "code" },
                        { title: "项目名称", dataIndex: "name" },
                        { title: "所属部门", dataIndex: "department" },
                        { title: "负责人", dataIndex: "personLiable" },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue
                    }
                    break;
                case 'currency'://币种
                    this.apiUrl = '/erp/currency/pageList';
                    this.columns = [
                        { title: "编码", dataIndex: "code" },
                        { title: "币名", dataIndex: "name" },
                        { title: "币符号", dataIndex: "currencySign" },
                        {
                            title: "折算方式",
                            dataIndex: "calDirection",
                            customRender: (text, row, index) => {
                                return text == 1 ? "原币*汇率=本位币" : "原币/汇率=本位币";
                            },
                            ellipsis: true,
                        },
                        {
                            title: "汇率设置方式",
                            dataIndex: "exChangeRateType",
                            customRender: (text, row, index) => {
                                return text == 1 ? "日汇率" : "月汇率";
                            }
                        }
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue
                    }
                    break;
                case 'purchaseType'://采购类型
                    this.apiUrl = '/erp/purchaseType/pageList';
                    this.columns = [
                        { title: "编码", dataIndex: "code" },
                        { title: "名称", dataIndex: "name" },
                        { title: "入库类别", dataIndex: "styleName" }
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue
                    }
                    break;
                case 'saleType'://销售类型
                    this.apiUrl = '/erp/saleType/pageList';
                    this.columns = [
                        { title: "销售类型编码", dataIndex: "code" },
                        { title: "销售类型名称", dataIndex: "name" },
                        { title: "出库类别", dataIndex: "styleName" },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue
                    }
                    break;
                case 'crm'://客户
                case 'crmCustomer'://客户
                    // this.apiUrl = '/erp/customer/page';
                    // this.columns = [
                    //     { title: "首拼码", dataIndex: "customerPym" },
                    //     { title: "客户编码", dataIndex: "customerCode", ellipsis: true, },
                    //     { title: "客户名称", dataIndex: "customerName", ellipsis: true, },
                    //     { title: "联系地址", dataIndex: "address", ellipsis: true, },
                    //     // { title: "客户类型", dataIndex: "partnerClassId", ellipsis: true, scopedSlots: { customRender: "partnerClassCustomer" }},
                    // ];
                    // this.postData = {
                    //     current: this.pagination.current,
                    //     size: this.pagination.pageSize,
                    // }
                    // break;
                    this.apiUrl = '/crm/customer/pageForVoucher';
                    this.columns = [
                        // { title: "首拼码", dataIndex: "crmSimpleName" },
                        { title: "客户名称", dataIndex: "crmName", ellipsis: true, },
                        { title: "所属地区", dataIndex: "areaName", ellipsis: true, },
                        { title: "所属行业", dataIndex: "industry", ellipsis: true, },
                        { title: "联系地址", dataIndex: "address", ellipsis: true, },
                        // { title: "客户类型", dataIndex: "partnerClassId", ellipsis: true, scopedSlots: { customRender: "partnerClassCustomer" }},
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        keyWord: this.inputValue,
                        isFinance: 1,
                        companyType: 'isCustomer'
                    }
                    break;
                case 'warehouse'://仓库
                    let path = this.$route.path;
                    if (path == '/inventory/bills/purchaseIn' || path == '/inventory/bills/productIn' || path == '/inventory/bills/saleOut' || path == '/inventory/bills/materialOut') {
                        //表示是库存管理里的采购入库
                        this.apiUrl = '/in/warehouse/listMyOperationInWarehouses'
                    } else {
                        this.apiUrl = '/in/warehouse/pageList';
                    }

                    this.columns = [
                        { title: "仓库编码", dataIndex: "whCode" },
                        { title: "仓库名称", dataIndex: "whName", ellipsis: true, },
                        { title: "负责人", dataIndex: "whPerson", ellipsis: true, },
                        { title: "电话", dataIndex: "whTelephone", ellipsis: true, },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        keyWord: this.inputValue,
                    }
                    break;
                case 'despatchType'://运输
                    this.apiUrl = '/erp/despatchType/pageList';
                    this.columns = [
                        { title: "发运方式编码", dataIndex: "code" },
                        { title: "发运方式名称", dataIndex: "name" }
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                    }
                    break;
                case 'invoiceType'://发票类型
                    this.apiUrl = '/erp/invoiceType/pageList';
                    this.columns = [
                        { title: "发票类型编码", dataIndex: "code" },
                        { title: "发票类型名称", dataIndex: "name" },
                        {
                            title: "方向",
                            dataIndex: "type",
                            customRender: (text) => {
                                return <span>{text == 1 ? "正发票" : "负发票"}</span>;
                            },
                        },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                    }
                    break;
                case 'clearmethod'://结算方式
                    this.apiUrl = '/erp/settleStyle/pageList';
                    this.columns = [
                        { align: "left", title: "结算方式编码", dataIndex: "code", width: "120" },
                        { align: "left", title: "结算方式名称", dataIndex: "name", width: "120" },
                        { align: "left", title: "默认账户", dataIndex: "bankAccount", width: "120" },
                    ];
                    this.pagination.pageSize = 100;
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                    }
                    break;
                case 'bank'://银行账户
                    this.apiUrl = '/erp/bankAccount/pageList';
                    this.columns = [
                        { align: "left", title: "账户名称", dataIndex: "accountName", width: "120", ellipsis: true },
                        { align: "left", title: "账户类型", dataIndex: "accountType", width: "120", customRender: (text, record, index) => { return text == 1 ? '银行账号' : text == 2 ? '微信账号' : text == 3 ? '支付宝账号' : text == 4 ? '个人银行卡' : '' } },
                        { align: "left", title: "开户银行", dataIndex: "bankName", width: "120", ellipsis: true },
                        { align: "left", title: "银行账号", dataIndex: "bankAccount", width: "120", ellipsis: true },
                        { align: "left", title: "币种", dataIndex: "currencyName", width: "120" }
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue
                    }
                    break;
                case 'rate'://汇率
                    this.apiUrl = '/erp/currency/getDetailList';
                    this.columns = [{
                        title: "序号", dataIndex: "index", width: 40, align: "center",
                        customRender: (text, record, index) => {
                            return index + 1
                        }
                    },
                    { title: "日期", dataIndex: "dateTitle", width: 120, align: "center" },
                    { title: "记账汇率", dataIndex: "exchangeRate", align: "left" },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        currencyId: this.dynamicData.rateId,//币种id
                    }
                    break;
                case 'accountingRadio'://会计科目单选
                    this.apiUrl = '/erp/accounting/page';
                    this.columns = [
                        { title: "科目编码", dataIndex: "code", key: "code", align: "left", width: 100 },
                        { title: "科目名称", dataIndex: "name", key: "name", align: "left", width: 100 },
                        {
                            title: "余额方向", dataIndex: "dcDirection", key: "dcDirection", align: "left", width: 100,
                            customRender: (text, row, index) => {
                                if (text) {
                                    return text == 1 ? "借方" : "贷方";
                                }
                            }
                        }
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                        // isEndNode: 1,
                    }
                    this.postData = Object.assign({}, this.postData, this.searchData);
                    break;
                case 'warehouseType'://出入库类别
                    this.apiUrl = '/in/rdStyle/pageStyleList';
                    this.columns = [
                        { title: "类别编码", dataIndex: "code", key: "code", align: "left", width: 100 },
                        { title: "类别名称", dataIndex: "name", key: "name", align: "left", width: 100 },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,

                        // isEndNode: 1,
                    }
                    break;
                case 'warehouseTypeIn'://入库类别
                    this.apiUrl = '/in/rdStyle/pageStyleList';
                    this.columns = [
                        { title: "类别编码", dataIndex: "code", key: "code", align: "left", width: 100 },
                        { title: "类别名称", dataIndex: "name", key: "name", align: "left", width: 100 },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                        type: 1,
                    }
                    break;
                case 'warehouseTypeOut'://出库类别
                    this.apiUrl = '/in/rdStyle/pageStyleList';
                    this.columns = [
                        { title: "类别编码", dataIndex: "code", key: "code", align: "left", width: 100 },
                        { title: "类别名称", dataIndex: "name", key: "name", align: "left", width: 100 },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                        type: 2,
                    }
                    break;
                case 'workProcedure'://工序档案
                    this.apiUrl = '/erp/workProcedure/pageList';
                    this.columns = [
                        { title: "工序编码", dataIndex: "code", width: "120", align: "left" },
                        { title: "工序名称", dataIndex: "name", width: "120", align: "left" },
                        {
                            title: "加工方式", dataIndex: "processMethod", width: "120", align: "left", customRender: (text, row, index) => {
                                const type = ["自制", "委外"];
                                return type[text - 1];
                            }
                        },
                        {
                            title: "工资类型", dataIndex: "wagesType", width: "120", align: "left", customRender: (text, row, index) => {
                                const type = ["计件", "计时", "不核算"];
                                return type[text - 1];
                            }
                        },
                        { title: "合格品价格", dataIndex: "qualifiedPrice", width: "120", align: "left" },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue
                    }
                    break;
                case 'productionLine'://生产线
                    this.apiUrl = '/erp/productionLine/pageList';
                    this.columns = [
                        { title: "生产线编码", dataIndex: "code", width: "120", align: "left" },
                        { title: "生产线名称", dataIndex: "name", width: "120", align: "left" },
                        { title: "所属车间", dataIndex: "officeName", width: "120", align: "left" },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue
                    }
                    break;
                case 'role'://角色
                    this.apiUrl = '/system/role/page';
                    this.columns = [
                        { title: "角色名称", dataIndex: "roleName", width: "120", align: "left" },
                        {
                            title: "数据范围", dataIndex: "dataScope", width: "120", align: "left",
                            customRender: (text, row, index) => {
                                if (text) {
                                    return text == 1 ? "本人数据" : text == 2 ? "部门数据" : text == 3 ? "公司数据" : text == 4 ? "跨部门数据" : text == 5 ? "自定义人员" : '';
                                }
                            }
                        },
                    ];
                    this.postData = {
                        'page.current': this.pagination.current,
                        'page.size': this.pagination.pageSize,
                        roleName: this.inputValue
                    }
                    break;
                case 'processRoute'://工艺路线
                    this.apiUrl = '/erp/processRoute/getList';
                    this.columns = [{ title: '编码', dataIndex: 'code', width: 30, ellipsis: true, },
                    { title: '名称', dataIndex: 'name', ellipsis: true, width: 120, ellipsis: true },
                    // { title: '产品编码', dataIndex: 'inventoryCode', width: 80 },
                    // { title: '产品名称', dataIndex: 'inventoryName', width: 80 },
                    // { title: '规格型号', dataIndex: 'inventorySpecification', width: 80 },
                    {
                        title: '状态', dataIndex: 'status', width: 60,
                        customRender: (text, row, index) => {
                            return text == 1 ? '启用' : '禁用';
                        }
                    }];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                        status: 1,            //状态1:正常 0停用
                        examineStatus: 1,    //审核状态1:已审 0:未审
                        // inventoryId: this.record.inventoryId ? this.record.inventoryId : ""
                    }
                    break;
                case 'contractType'://合同类型
                    this.apiUrl = '/cm/contractType/getList';
                    this.columns = [
                        { title: "类别编码", dataIndex: "code", key: "code", align: "left", width: 100 },
                        { title: "类别名称", dataIndex: "name", key: "name", align: "left", width: 100 },
                        {
                            title: "收付计划方向",
                            dataIndex: "planDirection",
                            align: "left",
                            width: 100,
                            customRender: (text, row, index) => {
                                if (text) {
                                    switch (text) {
                                        case 1: return "收";
                                        case 2: return "付";
                                        case 3: return "其他";
                                        default:
                                            break;
                                    }
                                }
                            }
                        }
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                    }
                    break;
                case 'stageGroup'://合同阶段组
                    this.apiUrl = '/cm/stageGroup/getList';
                    this.columns = [
                        { title: "阶段编码", dataIndex: "code", key: "code", align: "left", width: 100 },
                        { title: "阶段名称", dataIndex: "name", key: "name", align: "left", width: 100 },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                    }
                    break;
                case 'inventoryLocation'://货位
                    this.apiUrl = '/in/inventoryLocation/pageList';
                    this.columns = [
                        { title: "仓库名称131", dataIndex: "warehouseName" },
                        { title: "货位编码", width: 100, dataIndex: "code" },
                        { title: "货位名称", dataIndex: "name" },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        warehouseId: this.wherehouseId
                    }
                    break;
                default:
                    break;
            }
        }
    }
}
</script>
<style lang="less">
    .form-search-wrapper {
        margin-top: 10px;
    }

    .ant-table-tbody {
        cursor: pointer;
    }
</style>